home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / skipandgouls.swf / scripts / __Packages / SecretCodeInterface.as < prev   
Encoding:
Text File  |  2007-10-01  |  2.0 KB  |  88 lines

  1. class SecretCodeInterface extends sarbakan.visual.element.DynamicElement
  2. {
  3.    var mc;
  4.    static var SECRET_CODES = {RANDOM_WAFFLES:"sun",BONUS_LEVEL:"pow",SYRUP_WATER:"find",RESET:"reset"};
  5.    function SecretCodeInterface(l_mc)
  6.    {
  7.       super("secretCode");
  8.       this.setMC(l_mc);
  9.    }
  10.    function show()
  11.    {
  12.       this.setState("open");
  13.    }
  14.    function open()
  15.    {
  16.       if(this.stateFinished())
  17.       {
  18.          this.setState("idle");
  19.       }
  20.    }
  21.    function idle()
  22.    {
  23.       if(this.stateStarting())
  24.       {
  25.          this.initButtons();
  26.       }
  27.       if(Key.isDown(13))
  28.       {
  29.          this.onButtonValidate();
  30.       }
  31.    }
  32.    function good()
  33.    {
  34.       if(this.stateFinished())
  35.       {
  36.          this.setState("close");
  37.       }
  38.    }
  39.    function bad()
  40.    {
  41.       if(this.stateFinished())
  42.       {
  43.          this.setState("idle");
  44.       }
  45.    }
  46.    function close()
  47.    {
  48.       if(this.stateFinished())
  49.       {
  50.          this.disable();
  51.       }
  52.    }
  53.    function onButtonValidate()
  54.    {
  55.       _global.C.oPackaging.clickSound();
  56.       this.validateCode();
  57.    }
  58.    function onButtonBack()
  59.    {
  60.       _global.C.oPackaging.clickSound();
  61.       this.setState("close");
  62.    }
  63.    function initButtons()
  64.    {
  65.       this.mc.state.btValidate.onRelease = sarbakan.utils.Delegate.create(this,this.onButtonValidate);
  66.       this.mc.state.btBack.onRelease = sarbakan.utils.Delegate.create(this,this.onButtonBack);
  67.    }
  68.    function validateCode()
  69.    {
  70.       var _loc3_ = false;
  71.       for(var _loc4_ in SecretCodeInterface.SECRET_CODES)
  72.       {
  73.          if(this.mc.state.code.text.toLowerCase() == SecretCodeInterface.SECRET_CODES[_loc4_])
  74.          {
  75.             _global.C.unlockCode(_loc4_);
  76.             _loc3_ = true;
  77.             this.setState("good");
  78.             getURL("javascript:trackEvent(\'" + SecretCodeInterface.SECRET_CODES[_loc4_] + "\');","");
  79.             break;
  80.          }
  81.       }
  82.       if(!_loc3_)
  83.       {
  84.          this.setState("bad");
  85.       }
  86.    }
  87. }
  88.